<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>Document</title>
	</head>
	<body>
		<ul id="box">
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
		</ul>
	</body>
</html>
<script>
	var str = "aaabbcccd";


	// 存放去除重复后的字符
	var newArr = [];

	// 存放字符出现的次数
	var numArr = [];

	for (var i = 0; i < str.length; i++) {
		var index = newArr.indexOf(str[i]);
		if (index == -1) {
			// newArr[newArr.length] = str[i];
			newArr.push(str[i]);
			// numArr[numArr.length] = 1;
			numArr.push(1);
		} else {
			numArr[index]++;
		}
	}
	console.log(newArr);
	console.log(numArr);

	// 查找最大数
	var max = numArr[0];
	for (var i = 1; i < numArr.length; i++) {
		max = max > numArr[i] ? max : numArr[i];
	}
	console.log(max);
	// 找到最大数对应的下标
	// var index = numArr.indexOf(max);
	// var char = newArr[index];
	// console.log(char);

	for (var i = 0; i < numArr.length; i++) {
		if (numArr[i] == max) {
			console.log(newArr[i] + "出现的次数最多, 出现了" + max + "次");
		}
	}


	




</script>
